package cn.wolfcode.wolfcodemall.controller.fore;

import cn.wolfcode.wolfcodemall.domain.Product;
import cn.wolfcode.wolfcodemall.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 商品详情请求
 */
@Controller
public class ProductDetailsController {
    @Autowired
    private ProductService productService;

    //商品详情页
    @RequestMapping("/product/{productId}")
    public String productDetailsPage(@PathVariable Integer productId, Model model){
        //根据商品id查询商品信息
        Product product = productService.selectById(productId);
        //将商品信息带到页面显示
        model.addAttribute("product",product);

        return "/fore/productDetailsPage";
    }
}
